package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import cn.hutool.core.collection.CollectionUtil;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.vo.SysHotelFeaturesReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysHotelFeaturesMapper;
import com.ruoyi.system.domain.SysHotelFeatures;
import com.ruoyi.system.service.ISysHotelFeaturesService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 酒店特色Service业务层处理
 * 
 * @author dht
 * @date 2025-04-30
 */
@Service
public class SysHotelFeaturesServiceImpl implements ISysHotelFeaturesService 
{
    @Autowired
    private SysHotelFeaturesMapper sysHotelFeaturesMapper;

    /**
     * 查询酒店特色
     * 
     * @param featuresId 酒店特色主键
     * @return 酒店特色
     */
    @Override
    public SysHotelFeatures selectSysHotelFeaturesByFeaturesId(Long featuresId)
    {
        return sysHotelFeaturesMapper.selectSysHotelFeaturesByFeaturesId(featuresId);
    }

    /**
     * 查询酒店特色列表
     * 
     * @param sysHotelFeatures 酒店特色
     * @return 酒店特色
     */
    @Override
    public List<SysHotelFeatures> selectSysHotelFeaturesList(SysHotelFeatures sysHotelFeatures)
    {
        return sysHotelFeaturesMapper.selectSysHotelFeaturesList(sysHotelFeatures);
    }

    /**
     * 新增酒店特色
     * 
     * @param sysHotelFeatures 酒店特色
     * @return 结果
     */
    @Override
    public int insertSysHotelFeatures(SysHotelFeatures sysHotelFeatures)
    {
        sysHotelFeatures.setCreateTime(DateUtils.getNowDate());
        return sysHotelFeaturesMapper.insertSysHotelFeatures(sysHotelFeatures);
    }

    /**
     * 修改酒店特色
     * 
     * @param sysHotelFeatures 酒店特色
     * @return 结果
     */
    @Override
    public int updateSysHotelFeatures(SysHotelFeatures sysHotelFeatures)
    {
        sysHotelFeatures.setUpdateTime(DateUtils.getNowDate());
        return sysHotelFeaturesMapper.updateSysHotelFeatures(sysHotelFeatures);
    }

    /**
     * 批量删除酒店特色
     * 
     * @param featuresIds 需要删除的酒店特色主键
     * @return 结果
     */
    @Override
    public int deleteSysHotelFeaturesByFeaturesIds(Long[] featuresIds)
    {
        return sysHotelFeaturesMapper.deleteSysHotelFeaturesByFeaturesIds(featuresIds);
    }

    /**
     * 删除酒店特色信息
     * 
     * @param featuresId 酒店特色主键
     * @return 结果
     */
    @Override
    public int deleteSysHotelFeaturesByFeaturesId(Long featuresId)
    {
        return sysHotelFeaturesMapper.deleteSysHotelFeaturesByFeaturesId(featuresId);
    }


    @Override
    @Transactional
    public int addHotelFeatures(SysHotelFeaturesReq req) {
        req.checkParams();
        sysHotelFeaturesMapper.deleteSysHotelFeaturesRelaByHotelId(req.getHotelId());
        return sysHotelFeaturesMapper.addHotelFeatures(req.getHotelId(), req.getFeaturesIds());
    }

    @Override
    public List<SysHotelFeatures> getByHotelId(Long hotelId) {
        return sysHotelFeaturesMapper.getByHotelId(hotelId).stream().map(this::selectSysHotelFeaturesByFeaturesId).collect(Collectors.toList());
    }
}
